import JSEncrypt from "jsencrypt";
import Encrypt from 'encryptlong';

// export default{
  /** JSEncrypt加密 */
 export const rsaPublicData = (data, publickey) =>{
    var jsencrypt = new JSEncrypt()
    jsencrypt.setPublicKey(publickey)
    var result = jsencrypt.encrypt(data)
    return result
  };
  /**JSEncrypt解密 */
  export const rsaPrivateData = (data, privatekey) =>{
    var jsencrypt = new JSEncrypt()
    jsencrypt.setPrivateKey(privatekey)
    var result = jsencrypt.encrypt(data)
    return result
  };
  /**超长加密 */
  export const encrypt = (data, publickey) => {
    const PUBLIC_KEY = publickey
    var encryptor = new Encrypt()
    encryptor.setPublicKey(PUBLIC_KEY)
    // 如果是对象/数组的话，需要先JSON.stringify转换成字符
    const result = encryptor.encryptLong(data)
    return result
  };
  /** 解密 PRIVATE_KEY 验证 */
  export const decrypt = (data, privatekey) => {
    const PRIVATE_KEY= privatekey
    var encryptor = new Encrypt()
    encryptor.setPrivateKey(PRIVATE_KEY)
    // 如果是对象/数组的话，需要先JSON.stringify转换成字符
    var result = encryptor.decryptLong(data)
    return result
  }
// }